﻿using UnityEngine;
using System.Collections;

public class showPartner : MonoBehaviour
{
	Ray ray;
	RaycastHit hit;
	GameObject t;
	int sceneh, scenew, scenebl;
	GameObject T, S, P, txt;
	float f_s;
	string screen_s;
	//t：towerbloxx，s：score，p：showpartner

	// Use this for initialization
	void Start ()
	{
		
		print ("屏幕高：" + Screen.height);
		print ("屏幕宽：" + Screen.width);

		T = GameObject.Find ("TowerBloxx1");
		S = GameObject.Find ("Score");
		P = GameObject.Find ("showpartner");
		txt = GameObject.Find ("text");
		f_s = (float)Camera.main.pixelHeight / (float)Camera.main.pixelWidth;//(float)Screen.height / (float)Screen.width;
		screen_s = ((float)Camera.main.pixelHeight / (float)Camera.main.pixelWidth).ToString ("0.0000");

		//print ("childCount:" + it.transform.childCount);

		//	f_s = Mathf.Round (f * 10) / 10;

		//	print ("test :" + f_s + "/" + (float)Screen.height + "/" + (float)Screen.width);
		print ("test1 :" + screen_s);
		//	(((float)Camera.main.pixelWidth) / Camera.main.pixelHeight).ToString ("0.0000") f_s == (5f / 3f) 

		if (screen_s.Contains ("1.66")) {
			print ("is: 5 / 3" + 5f / 3f);
			txt.GetComponent<TextMesh> ().text = "is: 5 / 3";
			T.transform.localPosition = new Vector3 (-16.37f, 27.9f, 63.9f);
			S.transform.localPosition = new Vector3 (-25.43f, 47.11f, 108.6f);
			P.transform.localPosition = new Vector3 (42.72f, 59, 136.2f);
		} else if (screen_s.Contains ("1.3")) {
			print ("is: 4 / 3");
			txt.GetComponent<TextMesh> ().text = "is: 4 / 3";
			T.transform.localPosition = new Vector3 (-20.16f, 27.9f, 63.9f);
			S.transform.localPosition = new Vector3 (-31.56f, 47.11f, 108.6f);
			P.transform.localPosition = new Vector3 (42.72f, 59, 136.2f);
		} else if (screen_s.Contains ("1.4")) {
			print ("is: 7 / 5");
			txt.GetComponent<TextMesh> ().text = "is: 7 / 5";
			T.transform.localPosition = new Vector3 (-19.68f, 27.9f, 63.9f);
			S.transform.localPosition = new Vector3 (-31.56f, 47.11f, 108.6f);
			P.transform.localPosition = new Vector3 (42.72f, 59, 136.2f);
		} else if (screen_s.Contains ("1.6")) {
			print ("is: 16 / 10");
			txt.GetComponent<TextMesh> ().text = "is: 16 / 10";
			T.transform.localPosition = new Vector3 (-16.92f, 27.9f, 63.9f);
			S.transform.localPosition = new Vector3 (-26.56f, 47.11f, 108.6f);
			P.transform.localPosition = new Vector3 (35.62f, 59, 136.2f);
		} else if (screen_s.Contains ("1.5")) {
			print ("is: 3 / 2");
			txt.GetComponent<TextMesh> ().text = "is: 3 / 2";
			T.transform.localPosition = new Vector3 (-17.45f, 27.9f, 63.9f);
			S.transform.localPosition = new Vector3 (-27.3f, 47.11f, 108.6f);
			P.transform.localPosition = new Vector3 (36.2f, 59, 136.2f);
		} else if (screen_s.Contains ("1.7")) {
			print ("is:16 / 9");
			txt.GetComponent<TextMesh> ().text = "is: 16 / 9";
			T.transform.localPosition = new Vector3 (-18.3f, 34.9f, 63.9f);
			S.transform.localPosition = new Vector3 (-29f, 59f, 108.6f);
			P.transform.localPosition = new Vector3 (39.2f, 74, 136.2f);
		} else {
			print ("is:else");
			txt.GetComponent<TextMesh> ().text = "is: else";
			T.transform.localPosition = new Vector3 (-17.45f, 27.9f, 63.9f);
			S.transform.localPosition = new Vector3 (-27.3f, 47.11f, 108.6f);
			P.transform.localPosition = new Vector3 (36.2f, 59, 136.2f);
		}


	}
	
	// Update is called once per frame
	void Update ()
	{
		
		ray = Camera.main.ScreenPointToRay (Input.mousePosition);
		if (Input.GetKeyDown (KeyCode.Mouse0)) {
			if (Physics.Raycast (ray, out hit)) {			
				if (hit.transform.name.ToString () == "showpartner") {
					Debug.DrawLine (ray.origin, hit.point);
					Application.OpenURL ("http://" + "www.getqcoo.com?c=index&a=arshowpartner");
				}
			}
		}

	}
}
